@layout("/backend/common/_container.html"){
<script type="text/javascript">
    $(function () {
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引

        $("#btn_close").bind("click", function () {
            parent.layer.close(index); 
        });

        $("#btn_save").bind("click", function () {
            var ids = Sys.zTreeCheckedNodes("zTree");
            var ajax = new $ax(Sys.backendPath + "/shortcut/set_shortcut", function (data) {
                Sys.success("添加快捷方式成功!");
                if($("#shortcut").val()==0){
                	window.parent.Shortcut.table.refresh();
                	window.parent.parent.parent.ShortcutEdit();
                }else if($("#shortcut").val()==1){
            	   window.parent.ShortcutEdit();
                }
                parent.layer.close(index);
            }, function (data) {
                Sys.error("添加快捷方式失败!"
                    + data.responseJSON.message + "!");
            });
            ajax.set("createby",$("#createby").val());
            ajax.set("ids", ids);
            ajax.start();
        });

        initZtree();
        
    });
    
    function initZtree() {
        var setting = {
            check: {
                enable: true,
                nocheckInherit : false,
                chkboxType: {
                    "Y": "",
                    "N": ""
                }
            },
            data: {
                simpleData: {
                    enable: true
                }
            }
        };
        
        var ztree = new $ZTree("zTree", Sys.backendPath + "/shortcut/resourceTreeListByRoleId/"+$("#createby").val());
        ztree.setSettings(setting);
        ztree.init(); 
    }
</script>


<!-- 配置grid -->
<div class="container" style="padding:  0px 10px !important;margin-top: -10px;text-align: center !important;">
    <div class="row">
        <div class="box">
            <div class="box-body">
                <ul id="zTree" class="ztree"></ul>
            </div>
        </div>
    </div>
    <#Hidden id="shortcut" value="${shortcut}"/> 
    <#Hidden id="createby" value="${shiro.getUser().id}" />
    <div class="row">
        <div class="col-md-12">
            <button class="btn btn-sm btn-info" type="button" id="btn_save">
                <i class="ace-icon fa fa-check bigger-110"></i>保存
            </button>
            &nbsp;
            <button class="btn btn-sm btn-danger" type="button" id="btn_close">
                <i class="ace-icon fa fa-close bigger-110"></i>关闭
            </button>
        </div>
    </div>
</div>
@}